<?xml version="1.0"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:html="http://www.w3.org/1999/xhtml">
<xsl:output method="html"/>
<xsl:template match="/">
  <html>
  <head>
    <style type="text/css">
    table.gridtable {
	    font-family: verdana,arial,sans-serif;
	    font-size:11px;
	    color:#333333;
	    border-width: 1px;
	    border-color: #666666;
	    border-collapse: collapse;
    }
    table.gridtable th {
	    border-width: 1px;
	    padding: 8px;
	    border-style: solid;
	    border-color: #666666;
	    background-color: #dedede;
    }
    table.gridtable td {
	    border-width: 1px;
	    padding: 3px;
	    border-style: solid;
	    border-color: #666666;
	    background-color: #ffffff;
    }
    </style>
  </head>
  <body>
    <h2>DataTypes Definition</h2>
    <xsl:for-each select="DataTypes/DataType">
    <h3><xsl:value-of select="Name"/></h3>
    <p>Encoding: <xsl:value-of select="Encoding"/></p>
    <p><xsl:value-of select="Description/text()"/>
       <xsl:copy-of select="Description/tbl" /></p>
    <table class="gridtable">
      <tr>
        <th>Bit nr</th>
        <th>Description</th>
      </tr>
      <xsl:for-each select="RegDef/Bits">
        <tr>
            <xsl:choose>
              <xsl:when test="@start=@end">
                   <td><xsl:value-of select="@start"/></td> 
              </xsl:when>
              <xsl:otherwise>
                    <td><xsl:value-of select="@start"/> to <xsl:value-of select="@end"/></td>
              </xsl:otherwise>
            </xsl:choose>
            <td><xsl:value-of select="."/></td>
        </tr>
      </xsl:for-each>
    </table>
    <br></br>
    <table class="gridtable">
      <tr>
        <th>Pattern</th>
        <th>Description</th>
      </tr>
      <xsl:for-each select="BitPatternDef/Pattern">
        <tr>
            <td><xsl:value-of select="@value"/></td>
            <td><xsl:value-of select="."/></td>
        </tr>
      </xsl:for-each>
    </table>
    </xsl:for-each>
  </body>
  </html>
</xsl:template>

</xsl:stylesheet>
